package com.starbugs.wehcat.aop.product;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

/**
 * 切面类
 */
public class MyAspectXML {

  // 前置通知 joinPoint 切入点信息
  public void check(JoinPoint joinPoint){
    System.out.println("'权限校验'" + joinPoint);
  }

  // 后置通知
  public void writeLog(JoinPoint joinPoint, Object res){
    System.out.println("writeLog !!!" + joinPoint);
    System.out.println(res);
  }

  // 环绕通知
  public Object monitor(ProceedingJoinPoint joinPoint) throws Throwable {
    System.out.println("环绕通知 之前");
    Object obj = joinPoint.proceed();
    System.out.println("环绕通知 之后");
    return obj;
  }

  // 异常抛出通知
  public void exe(Throwable ex){
    System.out.println("异常抛出通知" + ex.getMessage());
  }

  public void after(){
    System.out.println("最终通知");
  }
}
